package com.uenpay.im.invokeitems.contacts;

import com.qiyunxin.android.http.net.HttpInvokeItem;
import com.uenpay.im.configuration.APIConfiguration;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * @author SL
 * @copyRight http://www.qiyunxin.com
 */
public class ReportFriendsInvokItem extends HttpInvokeItem {

	public class ReportFriendsInvokItemResult {
		public int status;
		public String msg;
	}

	public ReportFriendsInvokItemResult getOutput() {
		return (ReportFriendsInvokItemResult) GetResultObject();
	}

	public ReportFriendsInvokItem(String content, String to_cust_id,
			int spam_type_id, int type) {
		String url = "";
		if (type == 1) {
			url = APIConfiguration.getBaseUrl() + "/Friend/Friend/friendReport?"
					+ "custid=" + to_cust_id + "&content=" + content
					+ "&spamtype=" + spam_type_id + "&"
					+ APIConfiguration.getCustIdAndToken();
		} else {
			url = APIConfiguration.getBaseUrl() + "/Chat/Chat/chatReport?"
					+ "chatid=" + to_cust_id + "&content=" + content
					+ "&spamtype=" + spam_type_id + "&"
					+ APIConfiguration.getCustIdAndToken();
		}
		SetUrl(url);
	}

	@Override
	protected Object DeserializeResult(String responseBody) throws Exception {
		ReportFriendsInvokItemResult result = new ReportFriendsInvokItemResult();
		try {
			JSONObject json = new JSONObject(responseBody);
			result.status = json.optInt("status");
			result.msg = json.optString("msg");
		} catch (JSONException e) {
			e.printStackTrace();
			return result;
		}
		return result;
	}
}
